<h3>Tìm kiếm phân lớp</h3>

<form action="phanlop-timkiem" method="post">
	<table class="Form">
	
        <tr>
			<td width="40%">Lớp:</td>
			<td>
            	<select name="MaLop">
                	<?php
						
                    	$lop = new lopbs();
						$dmlop = $lop->GetList();
						for($i = 0; $i < (count($dmlop)); $i++)
						{
						
							echo "<option value='{$dmlop[$i]['MaLop']}'>{$dmlop[$i]['TenLop']}</option>";
							
							
						}
					?>
                </select>
            <span  class="requirefield">*</span></td>
		</tr>
        <tr>
			<td width="40%">Giáo viên:</td>
			<td>
            	<select name="MaGiaoVien">
                	<?php
                    	$giaovien = new giaovienbs();
						$dmgiaovien = $giaovien->GetList();
						for($i = 0; $i < (count($dmgiaovien)); $i++)
						{
							echo "<option value='{$dmgiaovien[$i]['MaGiaoVien']}'>{$dmgiaovien[$i]['TenGiaoVien']}</option>";
						}
					?>
                </select>
            <span  class="requirefield">*</span></td>
		</tr>
        
        <tr>
			<td width="40%">Sỉ số:</td>
			<td><input type="text" name="SiSo" class="required" /><span  class="requirefield">*</span></td>
		</tr>
         <tr>
			<td width="40%">Năm học:</td>
			<td>
            	<select name="NamHoc">
                	<?php
                    	$namhoc = new namhocbs();
						$dmnamhoc = $namhoc->GetListNamHoc();
						for($i = 0; $i < count($dmnamhoc); $i++)
						{
							echo "<option value='{$dmnamhoc[$i]['NamHoc']}'>{$dmnamhoc[$i]['NamHoc']}</option>";
						}
					?>
                </select>
            <span  class="requirefield">*</span></td>
		</tr>
       
         
         <tr>
        	<td colspan="2">
            		<input type="submit" value="Tìm kiếm" name="TimKiem" class="btn_timkiem" />
            </td>
        </tr>
	</table>
</form>

<?php
	if(isset($_POST['TimKiem']))
	{
		$MaLop = $_POST['MaLop'];
		$MaGiaoVien = $_POST['MaGiaoVien'];
		$SiSo = $_POST['SiSo'];
		$NamHoc = $_POST['NamHoc'];
		$phanlop = new phanlopbs();
		$phanlop->MaLop = $MaLop;
		$phanlop->MaGiaoVien = $MaGiaoVien;
		$phanlop->SiSo = $SiSo;
		$phanlop->NamHoc = $NamHoc;		
		$danhsach = $phanlop->GetList();
		if($danhsach)
		{
?>
      <table class="List">
	<tr>
		<th>SST</th>
		<th>Lớp</th>
		<th>Giáo viên</th>
        <th>Sỉ số</th>
        <th>Năm học</th>
        <th>DSHS</th>
		<th>Sửa</th>
		<th>Xóa</th>
	</tr>
	<?php
				for($i = 0; $i < count($danhsach); $i++)
				{
					$stt=$i+1;
					echo "<tr>";
						echo "<td>$stt</td>";
						echo "<td>{$danhsach[$i]['TenLop']}</td>";
						echo "<td>{$danhsach[$i]['TenGiaoVien']}</td>";
						echo "<td>{$danhsach[$i]['SiSo']}</td>";
						echo "<td>{$danhsach[$i]['NamHoc']}</td>";
						echo "<td><a href='danh-sach-" . $danhsach[$i]['MaLop'] . "'>DSHS</a></td>";
						echo "<td align='center'><a href='phanlop-sua-" . $danhsach[$i]['MaPhanLop'] . "'><img src='images/edit.png' title = 'Sửa'/></a></td>";
						echo "<td align='center'><a href='phanlop-xoa-" . $danhsach[$i]['MaPhanLop'] . "' onclick='return confirm(\"Bạn có muốn xóa " . $danhsach[$i]['MaPhanLop'] . " không?\")'><img src='images/delete.png' title = 'Xóa'/></a></td>";
					echo "</tr>";
				}
			?>
</table>
<?php
		}
		else
		{
			echo "<p>Không tìm thấy thấy kết quả nào!</p>";

		}
	}
?>